<?php
/*********************************************************************************
 * SugarCRM Community Edition is a customer relationship management program developed by
 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/

/*
 * Created on Apr 13, 2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
require_once('include/MVC/View/views/view.edit.php');
require_once('custom/modules/Tasks/TaskUtils.php');
 class customViewEdit extends ViewEdit{
	
 	function customViewEdit(){
 		parent::ViewEdit();
 	}
 	
 	private function get_task_new_name($deliverable_id)
	{
		$task_new_name = array();
		$deliverables =  new edanz_Deliverables();
                $deliverables->retrieve($deliverable_id);
		$task_new_name['deliverable_service']=$deliverables->service;
		$jobs =  new edanz_Jobs();
                $jobs->retrieve($deliverable->job_id);
		$task_new_name['job_name']=$jobs->name;
		return $task_new_name;
	}
	
 	function display() {
 		global $timedate, $current_user;
		$_REQUEST['return_action'] = "DetailView";
		
		$arr_where['record_id'] = $this->bean->id;
    	$arr_where['module'] = "Tasks";
    	$group_id = $this->bean->retrieve_relationships('securitygroups_records',$arr_where,'securitygroup_id');
    	$group = new SecurityGroup();
		$group->retrieve($group_id[0]['securitygroup_id']);
		$group_time_zone = $group->group_time_zone;
 		
		$cfg = new Configurator();
		$time_format = $current_user->getPreference('timef');  
		$date_format = $current_user->getPreference('datef');  
		$format = $date_format." ".$time_format;
 		if ($_POST['button1']=="Assign")
 		{
 			unset($this->ev->defs['templateMeta']['form']['buttons'][0]);  
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][2]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][3]);  
	 		unset($this->ev->defs['panels']['lbl_task_information']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGNMENT']);	
	 		unset($this->ev->defs['panels']['LBL_DECLINING_INFORMATION']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_FAST_FAIL_TASKFAST']);
	 		
	 		$taskutils = new TaskUtils();
			$this->bean->date_due = $taskutils->dueDefault($this->bean->deliverable_id,$group_time_zone);
	 		//Group GMT Time
			$this->bean->date_due = $timedate->to_display_date_time($this->bean->date_due);
			
 		}
 		else if($_POST['button1']=="Decline")
 		{
 			unset($this->ev->defs['templateMeta']['form']['buttons'][0]);  
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][1]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][3]);  
	 		unset($this->ev->defs['panels']['lbl_task_information']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGNMENT']);	
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGN_AN_EXPERT']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_FAST_FAIL_TASKFAST']);
 		}
 		else if($_POST['button1']=="Fast Fail")
 		{
 			unset($this->ev->defs['templateMeta']['form']['buttons'][0]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][1]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][2]);
	 				
	 		unset($this->ev->defs['panels']['lbl_task_information']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGNMENT']);	
	 		unset($this->ev->defs['panels']['LBL_DECLINING_INFORMATION']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGN_AN_EXPERT']);
	 		
 		}
 		else{
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][3]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][1]);
	 		unset($this->ev->defs['templateMeta']['form']['buttons'][2]);
	 		
	 		unset($this->ev->defs['panels']['LBL_PANEL_ASSIGN_AN_EXPERT']);
	 		unset($this->ev->defs['panels']['LBL_DECLINING_INFORMATION']);
	 		unset($this->ev->defs['panels']['LBL_PANEL_FAST_FAIL_TASKFAST']);
	 		
 		}
		$this->ev->process();
		echo $this->ev->display($this->showTitle);
		
		include_once ('modules/Administration/QuickRepairAndRebuild.php');
    	$repair = new RepairAndClear();
    	$repair->module_list = array('Tasks');
		$repair->clearTpls();
 	}
 }
?>
